#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>

#include "proto.h"


int main(int argc,char* argv[]){
	if(argc<2){
		fprintf(stderr,"Usaging..");
		exit(1);
	}
	int sd,ret;
	sd=socket(AF_INET,SOCK_DGRAM,0);
	if(sd<0){
		perror("socket");
		exit(1);
	}
	struct sockaddr_in raddr;
	//bind()
	raddr.sin_family=AF_INET;
	raddr.sin_port=htons(NETPORT);
	inet_pton(AF_INET,argv[1],&raddr.sin_addr);

	struct msg_st msg;
	strncpy(msg.name,"Yang",NAMESIZE);
	msg.chinese=htonl(99);
	msg.math=htonl(100);
	socklen_t raddr_len;
	raddr_len=sizeof(raddr);
	ret=sendto(sd,&msg,sizeof(msg),0,(void *)&raddr,raddr_len);

	close(sd);

	exit(0);
}
